<?php
/**
 * Created by yb.
 * Author: 1021948372@qq.com
 * Date: 2020/7/7 07:07
 */
namespace app\common\lib;

use app\common\controller\Base;

class Mail extends Base
{
    /**
     * 发送email
     * @return bool
     */
    public function sendEmail($to = '邮箱地址',$username = '姓名',$subject = '标题',$content = '内容',$author = '作者'){
        require_once $_SERVER['DOCUMENT_ROOT'] . '/../extend/PHPMailer/sendMail.php';
        $body = '';
        $body .= '<html><head></head><body><div style="font-family:黑体;min-height:300px; background:#57bfaa;min-width:300px;max-width: 1000px;border: 0px solid #ccc; margin: auto;">';
        $body .= '<div style="width: 100%;font-size:20px;text-align: center;background: #4484c5; height: 50px;color: #FFF;line-height: 50px">' . $author . '</div>';
        $body .= '<div style="padding: 20px;color: #fff">';
        $body .= '<h3>尊敬的【' . $username . '】你好：</h3>';
        $body .= '<p style="line-height: 30px">' . $content . '</p>';
        $body .= '<p style="line-height: 30px">此邮件为系统邮件，请勿直接回复！</p>';
        $body .= '<p style="text-align: right;">' . $author . '</p>';
        $body .= '<p style="text-align: right;">' . date('Y-m-d H:i:s') . '</p>';
        $body .= '</div>';
        $body .= '</div></body></html>';

        $mail_config = config(GlobalConfig::MAILER);
        $mailer = new \SendMail($mail_config);
        $status = $mailer->sendEmail($to,$subject,$body);
        return $status;
    }

}